<template>
  <div>
    <!-- 选择地址模态框 2018/3/7 11:44 zhangQ -->
    <Form ref="dispatchForm" :model="dispatchForm" :label-width="80">
      <FormItem label="选择地址" prop="address">
        <Input v-model="dispatchForm.address" style="width: 200px;" :disabled="Boolean(dispatchDriverInfo.shippingAddress)"></Input>
        <!--<autoSelect v-model="dispatchForm.address" field="key" label="key" search-keys="key,keyPy" :dataList="addressList" :dropAll="true" style="width: 200px;"></autoSelect>-->
      </FormItem>
      <FormItem label="联系人" prop="contacts">
        <Input v-model="dispatchForm.contacts" style="width: 200px;" :disabled="Boolean(dispatchDriverInfo.contacts)"></Input>
      </FormItem>
      <FormItem label="电话" prop="mobile">
        <Input v-model="dispatchForm.mobile" style="width: 200px;" :disabled="Boolean(dispatchDriverInfo.contactsMobile)"></Input>
      </FormItem>
      <div class="xlinkModal-footer">
        <Button type="primary" @click="onOk">确认派单</Button>
      </div>
    </Form>
  </div>
</template>

<script>
  export default {
    name: 'check-address-modal',
    data () {
      let dispatchForm = { address: '', mobile: '', contacts: '' }
      let datas = { dispatchForm }
      return datas
    },
    props: {
      dispatchDriverInfo: {
        type: Object,
        default () {
          return {}
        }
      },
      addressList: {
        type: Array,
        default () {
          return []
        }
      }
    },
    computed: {},
    methods: {
      onOk () {
        if (!this.dispatchForm.address) {
          this.$Message.error('地址不能为空')
          return
        }
        this.$refs['dispatchForm'].validate((valid) => {
          if (valid) {
            this.$emit('dispatch', this.dispatchForm)
          } else {
          }
        })
      }
    },
    created () {
    },
    mounted () {
      this.dispatchDriverInfo.shippingAddress && (this.dispatchForm.address = this.dispatchDriverInfo.shippingAddress)
      this.dispatchDriverInfo.contacts && (this.dispatchForm.contacts = this.dispatchDriverInfo.contacts)
      this.dispatchDriverInfo.contactsMobile && (this.dispatchForm.mobile = this.dispatchDriverInfo.contactsMobile)
    },
    components: {}
  }
</script>

<style scoped>

</style>
